package xin.altitude.mybatisplus.request.merge.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import xin.altitude.common.entity.AjaxResult;
import xin.altitude.mybatisplus.request.merge.domain.Book;
import xin.altitude.mybatisplus.request.merge.service.BookService;

/**
 * @author explore
 * @date 2020/11/14 16:47
 */
@RestController
public class BookController {
    @Autowired
    private BookService bookService;
    
    /**
     * 并发查询商品详情
     *
     * @param id
     * @return
     */
    @GetMapping("/book/{id}")
    public AjaxResult index(@PathVariable Long id) {
        return AjaxResult.success(bookService.getById(id));
    }
    
    /**
     * 保存数据
     */
    @PostMapping("/book/add")
    public Boolean add(@RequestBody Book book) {
        return book.insert();
    }
}
